import { AddPostionParam, EditPositionParam, GetPositionParam, PositionDetailListType, PositionDetailParam, PostionMemberParam } from "@Tea/model"
import { PositionRepository } from "../repo/PositionRepository"
import { DataAndTotal } from "../types"

export class PositionManageContext {
  private static inst: PositionManageContext
  private repo: PositionRepository = PositionRepository.getInstance()

  public static  getInstance() {
    if (!PositionManageContext.inst) {
      PositionManageContext.inst = new PositionManageContext()
    }

    return PositionManageContext.inst
  }

  // 获取职位列表的操作
  async getPositionList(params: GetPositionParam) {
    return (await this.repo.getPositionList(params))[0]
  }

  // 获取职位详情
  async getPositionDetail(params: PositionDetailParam) {
    return this.repo.getPositionDetail(params)
  }

  // 添加职位
  async addPosition(params: AddPostionParam) {
    return this.repo.addPosition(params)
  }

  async editPosition(params: EditPositionParam) {
    return this.repo.editPosition(params)
  }

  // 添加职位
  async delPosition(positionCode:string) {
    return this.repo.delPosition(positionCode)
  }

  async addMember(param: PostionMemberParam) {
    return this.repo.addMember(param)
  }
  async delMember(id: number) {
    return this.repo.delMember(id)
  }
}